<template>
  <div class="home_con">
    <el-row>
      <el-col :span="8" v-for="item in ddArr" :key="item.id" class="dingdan">
        <div class="dd_item">
          <img :src="item.img" alt="cc" class="dd_img"/>
            <div class="box">
          <p>{{item.name}}</p>
          <p>{{item.price}}</p>
        </div>
        </div>
      
      </el-col>
   
    </el-row>
    <div class="swbox1">
    <p class="p1"><span>待处理事务</span></p>
      <ul  class="list1">
        <li v-for="itema in daichuliArr" :key="itema.id">
          <p class="p11">{{itema.name}}</p> 
          <p class="p22">( {{itema.num}} )</p>
        </li>
      </ul>
    </div>
    <div class="zlbox">
      <div class="zlbox1">
        <p class="p1"><span>商品总览</span></p>
        <ul class="list11">
          <li v-for="itemb in shangpinArr" :key="itemb.id">
            <p class="p11">{{itemb.num}}</p>
            <p class="p12">{{itemb.name}}</p>
          </li>
        </ul>
      </div>
      <div class="zlbox2">
        <p class="p1"><span>商品总览</span></p>
        <ul class="list11">
          <li v-for="itemc in yonghuArr" :key="itemc.id">
            <p class="p11">{{itemc.num}}</p>
            <p class="p12">{{itemc.name}}</p>
          </li>
        </ul>
      </div>
    </div>

    <div class="tb">
        <div id="tb1"></div>
        <div id="tb2"></div>
        <div id="tb3"></div>
    </div>

  </div>
</template>

<script>
export default {
  name:"home",
  data(){
    return{
      ddArr:[
        {id:1,
        name:"今日订单数",
        price:'200',
        img:require("@/assets/images/home_order.png")
        },
        {id:2,
        name:"今日销售总额",
        price:'￥5000',
        img:require("@/assets/images/home_today_amount.png")
        },
        {id:3,
        name:"昨日销售总额",
        price:'￥300',
        img:require("@/assets/images/home_yesterday_amount.png")
        },
      ],
      daichuliArr: [
        { id: 1, name: "代付款订单", num: 10 },
        { id: 2, name: "已完成订单", num: 5 },
        { id: 3, name: "待确认收货订单", num: 20 },
        { id: 4, name: "代发货订单", num: 30 },
        { id: 5, name: "新缺货登记", num: 6 },
        { id: 6, name: "待处理退款申请", num: 8 },
        { id: 7, name: "已发货订单", num: 12 },
        { id: 8, name: "待处理退货订单", num: 9 },
        { id: 9, name: "广告位即将到期", num: 10 },
      ],
      option: {
        //图表数据
        //x轴数据
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        //y轴
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [400, 200, 150, 80, 70, 110, 200],
            type: "bar",
            showBackground: true,
            backgroundStyle: {
              color: "rgba(180, 180, 180, 0.2)",
            },
          },
        ],
      },
      option22:{
        title: {
          text: '商品总览',
         
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: [
            
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              },
            },
          },
        ],
      },
      option33: {
        xAxis: {
          type: 'category',
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260

            ],
            type: 'line'
          }
        ]
      },
      shangpinArr: [
        { id: 1, name: "已下架", num: 100 },
        { id: 2, name: "已上架", num: 400 },
        { id: 3, name: "库存紧张", num: 50 },
        { id: 4, name: "全部商品", num: 500 },
      ],
      yonghuArr: [
        { id: 1, name: "今日新增", num: 100 },
        { id: 2, name: "昨日新增", num: 200 },
        { id: 3, name: "本月新增", num: 1000 },
        { id: 4, name: "会员总数", num: 5000 },
      ],
      tongjiArr: [
        { id: 1, name: "本月订单统计", num: 1000, type: 10, dec: "同比上月" },
        { id: 2, name: "本周订单总数", num: 1000, type: -10, dec: "同比上周" },
        { id: 3, name: "本月销售总额", num: 100000, type: 10, dec: "同比上月" },
        { id: 4, name: "本月销售", num: 50000, type: -10, dec: "同比上周" },
      ],
     
      
    }
  },
  mounted() {
    console.log(this.$echarts);
    this.option1();
    this.option2();
    this.option3();
    //初始化 图表
  },
  methods:{
    option1:function(){
      let tb1 = this.$echarts.init(document.getElementById('tb1'))
      console.log(tb1);
      tb1.setOption(this.option);
    },
    option2:function(){
      let tb2 = this.$echarts.init(document.getElementById('tb2'))
      console.log(tb2);
      var data=[];
      this.shangpinArr.forEach((item1)=>{
        data.push({value: item1.num, name: item1.name});
      });
      this.option22.series[0].data=data;
      tb2.setOption(this.option22);
    },
    option3:function(){
      let tb3 = this.$echarts.init(document.getElementById('tb3'));
      console.log(tb3);
      tb3.setOption(this.option33)
    }


  },
} 
</script>

<style lang='scss'>
*{
  margin: 0;
  padding: 0;

}
ul{
 list-style: none;
}
 

.home-con {
  padding: 10px;
}

.dd_item {
  border: 1px solid #ccc;
  margin: 10px;
  display: flex;
  justify-content: space-around;
  border-radius: 10px;
  height: 80px;
  
}
.dd_img {
  width: 50px;
  height: 50px;
  margin-top: 15px;
  
}
.box{
  margin-top: 15px;
}
.swbox1{
  margin: 10px;
  height: 180px;
  
  border: 1px solid #ccc;

}
.p1{
  // margin: 10px;
  width: 100%;
  height: 40px;
  line-height: 40px;
  font-size: 16px;
  font-weight: bold;
  
  background: rgb(242,246,252);
  span{
    margin-left: 10px;
  }
}
.list1{
  width: 100%;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  li{
    
    width: 30%;
    display: flex;
    height: 40px;
    font-size: 14px;
    line-height: 40px;
    border-bottom: 1px solid rgb(176, 203, 243);
    .p11{
      width: 80%;
      // border: 1px solid red;
      
    }
    .p22{
      color: red;
    }
  }
}
.zlbox{
  display: flex;
  .zlbox1{
    margin: 10px;
    width:50%;
    height: 130px;
    border: 1px solid #ccc;
    .list11{
      width: 100%;
      display: flex;
      
      justify-content: space-around;
      flex-wrap: wrap;
      // border: 1px solid red;
      text-align: center;
      margin-top: 20px;
      font-size: 14px;
    }
    .p11{
        color: red;
    }
    .p12{
      margin-top: 10px;
    }
  }
  .zlbox2{
      margin: 10px;
    width:50%;
    height: 130px;
    border: 1px solid #ccc;
    .list11{
      width: 100%;
      display: flex;
      justify-content: space-around;
      flex-wrap: wrap;
      // border: 1px solid red;
      text-align: center;
      margin-top: 20px;
      font-size: 14px;
      
      
    }
    .p11{
        color: red;
    }
    .p12{
      margin-top: 10px;
    }

  }
}

.tb{
  display: flex;
  justify-content: space-around;
  height: 400px;
}
#tb1{
    width: 30%;
    height: 300px;
  }
#tb2{
  height: 300px;
    width: 30%;

}
#tb3{
  height: 300px;
    width: 30%;

}

  


</style>